<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>内容修改页</title>
<link rel="stylesheet" href="${base}/images/contentImage/main.css" />
<link rel="stylesheet" type="text/css" href="${base}/js/uploadify/uploadify.css"/>

<script type="text/javascript" src="${base}/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${base}/js/ajaxupload.js"></script>

<script type="text/javascript" src="${base}/js/My97DatePicker4_8/WdatePicker.js"></script>
<script type="text/javascript" src="${base}/js/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="${base}/js/uploadify/jquery.uploadify.min.js"></script>
<script language="javascript">
var base = '${base}';
var api = frameElement.api, W = api.opener, D = W.document; 

function trim(str){ 
	  return str.replace(/^\s+|\s+$/g,''); 
} 

function tabChange(obj,id)
{
	
 var arrayli = obj.parentNode.getElementsByTagName("li"); //获取li数组
 var arrayul = document.getElementById(id).getElementsByTagName("li"); //获取li数组
 for(i=0;i<arrayul.length;i++)
 {
  if(obj==arrayli[i])
  {
	  arrayli[i].className="on";

	  arrayul[i].className = "showtab";
	 
  }
  else
  {
	   arrayli[i].className="";
   
      arrayul[i].className = "noshowtab";
	  
  }
 }
}

	function saveContent(){
		if(trim($("#title").val())=="")
        {
			$.dialog.alert("请输入标题");

        }else{
        	editor.sync();
        	$.dialog.tips('文章保存中...',999999,'loading.gif');
			var f = $("#tableForm");
			f.submit();
        }
	}
	//预览图片
	function imgShow(name) {
		if($("#"+name).val()=="") {
			$.dialog.alert("请先选择上传图片");
			return;
		}
		var path = $("#"+name).val();
		var url = '<img src="'+path+'"  />';
		 $.dialog({
			lock: true,
			width:'700px',
			height:'315px',
			content: url,
			cancelVal: '关闭',
			autoSize:true,
		    cancel: function(){ //请求成功后处理函数。
		    	
			}
		});

	}
	function initUploadButton(buttonId){
		var button = $("#"+buttonId);
		var exts = "jpg|png|gif",paths = "|";
		new AjaxUpload(button,
		{   
   			action: '${base}/content/admin/uploadImage.htm',   
   			name: 'uploadFile',
    		onSubmit : function(file, ext)
    		{     
           		if ( !RegExp( "\.(?:" + exts + ")$$", "i" ).test(file) ) 
           		{
           			$.dialog.alert("只能上传以下类型：" + exts).zindex();
					return false;
				}          		         
   		 	},   
   		 	onComplete: function(file, response,statusText)
   		 	{   
				var response = jQuery.parseJSON(response);
   		 		//eval("var response = " + response + ";");
   		 		if(response.status=="error")
				{
   		 			$.dialog.alert("上传失败！") ;
				}
				else 
				{
					$("#"+buttonId+"Path").val(response.path);
					$.dialog.alert("上传成功！") ;
				}
    		}   
		}); 
	}
	
	
	
	function clearImage(id){
		
		$("#"+id).val("");
	}

</script>

<script type="text/javascript" charset="utf-8">
    window.UEDITOR_HOME_URL = "${base}/ueditor/";  //UEDITOR_HOME_URL、config、all这三个顺序不能改变
</script>
<script type="text/javascript" src="${base}/ueditor/editor_config.js"></script>
<script type="text/javascript" src="${base}/ueditor/editor_all_min.js"></script>

	<script>
	$(document).ready(function(){
		<#if result??>

	        <#if result==true>
				$.dialog.alert("保存成功！");
			<#else>
		     	$.dialog.alert("保存失败！");
			</#if>

		</#if>
		
		initUploadButton("typeImage");
		initUploadButton("titleImage");
	});

</script>

</head>

<body style="background-color:#ffffff;">

<form action="${base}/content/admin/updateContent.htm" method="post" id = "tableForm" style="padding-top:5px;">


<input type="hidden" value="${(content.contentId)!}" name="contentId" />
<input type="hidden" value="${(channel.channelId)!}" name="channelId" />

<div class="titbg02">
<ul class="p_tab">
		<li  onclick="tabChange(this,&#39;tabcontent&#39;)" class="on">基本内容</li>
        <li  onclick="tabChange(this,&#39;tabcontent&#39;)">扩展功能</li>
    </ul>
</div>

<div class="w100" style="border-bottom:2px solid #2b88ad;">


</div>
<div id="tabcontent">
<ul>
	<li class="showtab">
<table width="98%" border="0" cellspacing="1" cellpadding="2" class="border-t" style="border-left:1px solid #bed3df;border-right:1px solid #bed3df;margin:5px auto;">
<tbody>
		<tr >
			<td  class="itemtit">当前栏目:</td><td width="90%" class="border_b" colspan="3">
				${(channel.title)!}
			</td>
		</tr>
		<tr >
			<td  class="itemtit"><span style="color:#FF0000;">*</span>标题:</td><td width="90%" class="border_b" colspan="3">
				<input class="w150" type="text" name="title" id="title" value="${(content.title)!}"/>
			</td>
		</tr>

		
		<tr>
		
			<td  class="itemtit">内容:</td>
			<td width="90%" class="border_b" colspan="3">
			<textarea  name="txt" id = "ueditTxt"  >
			
			
			
			${(content.txt?html)!}
			
			
			
			</textarea>
			<script type="text/javascript">
					var editor = new UE.ui.Editor({ initialFrameWidth:640 , minFrameHeight:170  });
   					        editor.render("ueditTxt");

			</script>
			

			</td>
		
		</tr>
		
		
		</tr>
		

</tbody>
</table>
    </li>
    
    
<li class="noshowtab">
<table width="98%" border="0" cellspacing="1" cellpadding="2" class="border-t" style="border-left:1px solid #bed3df;border-right:1px solid #bed3df;margin:5px auto;">
    <tr>
		<td class="itemtit">缩略图:</td>
		<td  class="border_b"   valign="top"  colspan="3">
			<input type ="text" id="typeImagePath" name="typeImage" style="width:220px" readonly="readonly" value="${(content.typeImage)!}"/>
			
			<input id="typeImage"  type="button" value="上传">
			<input id="cleartypeImage" onclick="clearImage('typeImagePath')" type="button" value="清除">
			<input type="button" value="预览" onclick="imgShow('typeImagePath')"/>
			 
			<br />上传类型：*.png;*.bmp;*.jpeg;*.jpg
		</td>	
		<td  class="border_b" align="left" valign="middle" >	
			
		</td>
    </tr>
    <tr>
		<td class="itemtit">展示图:</td>
		<td  class="border_b"   valign="top"  colspan="3">
			<input type ="text" id="titleImagePath" name="titleImage" style="width:220px" readonly="readonly" value="${(content.titleImage)!}"/>
			
			<input id="titleImage"  type="button" value="上传">
			<input id="cleartitleImage" onclick="clearImage('titleImagePath')" type="button" value="清除">
			<input type="button" value="预览" onclick="imgShow('titleImagePath')"/>
			 
			<br />上传类型：*.png;*.bmp;*.jpeg;*.jpg
		</td>	
		<td  class="border_b" align="left" valign="middle" >	
			
		</td>
    </tr>

<tr id="tr-releaseDate">


<td  class="itemtit">发布时间:</td><td  class="border_b" colspan="1">
<input type="text"  style="width:140px" class="w150"   name="createDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"<#if content??&&content.createDate??>value="${(content.createDate)?string('yyyy-MM-dd HH:mm:ss')}"</#if> /> 留空则为当前时间</td>

     <td class="itemtit">优先级：</td>
     <td colspan="1" class="border_b">
		<input type="text" style="width:100px" name="priority"  maxlength="55" class="w150" value="${(content.priority)!}" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"  />
     </td>

</tr>
<tr>


<td  class="itemtit">内容类型:</td><td class="border_b" >
	<select  name="contentType"  >

			<option value="1" <#if content??&&content.contentType ==1>selected="selected"</#if> >普通</option>
			<option value="2" <#if content??&&content.contentType ==2>selected="selected"</#if> >图文</option>
	</select>
</td>
        <td class="itemtit">是否外链：</td>
        <td class="border_b"  >
        	<label><input type="checkbox" onclick="$('#linkDiv').toggle(this.checked);if(!this.checked){$('#link').val('');}" <#if content??&&content.hasLink==1> checked="checked"</#if> >是</label>
            <br />
            <div id="linkDiv" <#if content??&&content.hasLink==1> <#else>style="display:none" </#if> >url:<input type="text" id="link" name="link" size="35" maxlength="255" value="${(content.link)!}" />
        </td>


</tr>




    


 </table>
    </li>

</ul>
</div>
</form>
</body>
</html>
